<script setup>
const props = defineProps(['student'])
const emit = defineEmits(['update:student'])

// 模拟名称被修改，看看是否是双向绑定
setTimeout(() => {
    // 如果student是个对象，这边也要传递对象
    emit('update:student', {
        name: '小黑',
        age: props.student.age,
        gender: props.student.gender
    });
}, 2000);
</script>

<template>
    <div>
        {{ student.name }}-{{ student.age }}-{{ student.gender }}
    </div>
</template>

<!-- <script setup>
const props = defineProps(['student'])
const emit = defineEmits(['update:student'])

// 模拟名称被修改，看看是否是双向绑定
setTimeout(() => {
    // 如果student是个对象，这边也要传递对象
    emit('update:student', '小黑');
}, 2000);
</script>

<template>
    <div>
        {{ student.name }}-{{ student.age }}-{{ student.gender }}
    </div>
</template> -->